package com.cplatform.cat.java8;

import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;

public class ProFruit {
    static Map<String, Function<Integer,Apple>> map =  new HashMap<>();
    static {
        map.put("红苹果",Apple::new);
        map.put("绿苹果",Apple::new);
    }
    public static Apple proApple(String apple,Integer weight){
        return map.get(apple).apply(weight);

    }

    public static void main(String[] args) {
        List<Apple> inventory = new ArrayList<>();
        inventory.add(new Apple(80,"green"));
        inventory.add(new Apple(155, "green"));
        inventory.add(new Apple(120, "red"));
        Predicate<Apple> redApp = (apple) -> "red".equals(apple.getColor());
        inventory.removeIf(redApp.negate());
        System.out.println(inventory);
        List<Apple> inventory1 = Arrays.asList(new Apple(80,"green"),
                new Apple(155, "green"),
                new Apple(120, "red"));
        inventory.size();
//        System.out.println(proApple("红苹果",1));
    }
}
